/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author BENSON
 */
public class ControllerReceptionLogin {
     /**
     * variables and object declarations
     */
   
    Views.ReceptionLogin repLogin;
    ActionListener actionListener;
    Model.MainModel model;
    
    /**
     * Constructor
     */
    public ControllerReceptionLogin( ){
        repLogin = new Views.ReceptionLogin();
        repLogin.setVisible(true);
        model= new Model.MainModel();
                          
    }
    
    /**
     * Method to get source of button clicked using action listener
     */
     public void control(){        
        actionListener = new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent actionEvent) {  
                  if(actionEvent.getSource()==repLogin.getRLoginBtn()){
                       if ((repLogin.getRUsername().getText().equals("visitor"))&&(repLogin.getRPassword().getText().equals("visitor"))){
                        ControllerReceptionHomepage repHomepage= new ControllerReceptionHomepage();  
                        repHomepage.control();
                        repLogin.setVisible(false);
                       }
                       else{
                           model.showReceptionist(repLogin);
                       }
                  }
                                    
              }
              
        };                
        repLogin.getRLoginBtn().addActionListener(actionListener);
    }  
    
}
